﻿using QiuShiBaiKe.DAL;
using QiuShiBaiKe.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace QiuShiBaiKe.BLL
{
    public class MessageBLL
    {
        private QiuShiBaiKe.Model.QiuShiBaiKeDBEntities entity;
        private MessageDAL msgDal;
        public MessageBLL(QiuShiBaiKe.Model.QiuShiBaiKeDBEntities entity)
        {
            this.entity = entity;
            msgDal = new MessageDAL(entity);
        }

        /// <summary>
        /// 根据主键获得糗事
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public Message GetById(long id)
        {
            return msgDal.GetById(id);
        }

        public long Add(long userId, string msg, bool isAnonymous, string imageUrl)
        {
            return msgDal.Add(userId, msg, isAnonymous, imageUrl);
        }

        /// <summary>
        /// 获得第pageIndex页的数据，每一页显示pageSize条
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        public Message[] GetMessages(int pageIndex, int pageSize)
        {
            return msgDal.GetMessages(pageIndex, pageSize);
        }

        /// <summary>
        /// 获得消息的总条数
        /// </summary>
        /// <returns></returns>
        public int GetMessagesCount()
        {
            return msgDal.GetMessagesCount();
        }
    }
}
